package com.youxin.cpcenter.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.youxin.busfoundation.bean.ResponseObject;
import com.youxin.busfoundation.bean.ent.RequestEntMemberIdentifyCapitalBean;
import com.youxin.busfoundation.bean.login.UserInfo;
import com.youxin.busfoundation.common.LoginAuth;
import com.youxin.cpcenter.common.log.LogMethod;
import com.youxin.cpcenter.service.EntMemberIdentifyCapitalService;
import com.youxin.foundation.utils.ObjectUtils;


/**
 * 
 * @ClassName: EntMemberIdentifyCapitalController 
 * @Description: 企业认证资本金券和可用线索等 
 * @author yingde.cao
 * @date 2017年12月9日 下午4:05:52 
 *
 */
@RestController
public class EntMemberIdentifyCapitalController extends BaseController{

	@Autowired
	private EntMemberIdentifyCapitalService service;
	
	@LogMethod(id="ent.coupon.update.")
	@RequestMapping(value = "/api/ent/coupon/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseObject couponUpdate(HttpServletRequest request, HttpServletResponse httpServletResponse,
			@RequestBody RequestEntMemberIdentifyCapitalBean bean) {
		try {
			ObjectUtils.requestNonNull(bean, "参数为空");
			return service.increaseCoupon(bean);
		} catch (Exception e) {
			logger.error("/api/ent/coupon/update异常", e);
			return ResponseObject.systemError(e);
		}
	}
	@LogMethod(id="ent.consum.details.")
	@RequestMapping(value = "/api/ent/consum/details", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
	public ResponseObject consumDetails(HttpServletRequest request, HttpServletResponse httpServletResponse,
			@RequestBody RequestEntMemberIdentifyCapitalBean bean) {
		try {
			UserInfo userInfo = LoginAuth.getUserInfo();
			bean.setEntIdentifyId(userInfo.getEntIdentifyId());
			return service.selectByPrimaryKey(bean);
		} catch (Exception e) {
			logger.error("/api/ent/consum/details异常", e);
			return ResponseObject.systemError(e);
		}
	}

}
